package top.jamewen.framework.sbmp.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.transaction.annotation.Transactional;
import top.jamewen.framework.sbmp.common.model.UmsAdmin;
import com.baomidou.mybatisplus.extension.service.IService;
import top.jamewen.framework.sbmp.common.model.UmsResource;
import top.jamewen.framework.sbmp.model.qo.UmsAdminQO;
import top.jamewen.framework.sbmp.model.qo.UpdateAdminPasswordQO;

import java.util.List;

/**
 * <p>
 * 后台用户表 服务类
 * </p>
 *
 * @author jamewen
 * @since 2021-01-11
 */
public interface UmsAdminService extends IService<UmsAdmin> {

    /**
     * 根据用户名获取用户信息
     */
    UmsAdmin getAdminByUsername(String username);

    /**
     * 根据用户名或昵称分页查询用户
     */
    Page<UmsAdmin> list(String keyword, Integer pageSize, Integer pageNum);

    /**
     * 修改指定用户信息
     */
    @Transactional(rollbackFor = Exception.class)
    boolean update(Long id, UmsAdmin admin);

    /**
     * 获取用户信息
     * @author JameWen
     * @date 2021/1/13
     * @param username
     * @return org.springframework.security.core.userdetails.UserDetails
     */
    UserDetails loadUserByUsername(String username);

    /**
     * 获取指定用户的可访问资源
     */
    List<UmsResource> getResourceList(Long adminId);

    /**
     * 后台用户注册
     * @author JameWen
     * @date 2021/1/12
     * @param adminQo
     * @return java.lang.String
     */
    @Transactional(rollbackFor = Exception.class)
    String register(UmsAdminQO adminQo);

    /**
     * 登录
     * @author JameWen
     * @date 2021/1/13
     * @param username
     * @param password
     * @return java.lang.String
     */
    String login(String username, String password);

    /**
     * 修改密码
     * @author JameWen
     * @date 2021/1/14
     * @param param
     * @return int
     */
    @Transactional(rollbackFor = Exception.class)
    int updatePassword(UpdateAdminPasswordQO param);

    /**
     * 删除指定用户
     * @author JameWen
     * @date 2021/1/14
     * @param id
     * @return boolean
     */
    @Transactional(rollbackFor = Exception.class)
    boolean delete(Long id);
}
